# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2023年03月22日
"""
import openpyxl
from PIL import Image

myBook=openpyxl.load_workbook('新书订购表.xlsx')
mySheet=myBook.active
myImage1=openpyxl.drawing.image.Image('images/myImage1.jpg')
mySheet.add_image(myImage1,'A5')
myImage2=Image.open('images/myImage2.jpg')
myCropedImage=myImage2.crop((39,11,167,188))
myCropWidth,myCropHeight=myCropedImage.size
myNewImage=Image.new('RGB',(256,354),'white')
myNewWidth,myNewHeight=myNewImage.size
for myLeft in range(0,myNewWidth,myCropWidth-50):
	for myTop in range(0,myNewHeight,myCropHeight-50):
		myNewImage.paste(myCropedImage,(myLeft,myTop))
myNewImage.save('temp/myImage2.jpg')
myNewImage2=openpyxl.drawing.image.Image('temp/myImage2.jpg')
mySheet.column_dimensions['B'].width=32
mySheet.row_dimensions[5].height=268
mySheet.add_image(myNewImage2,'B5')



myBook.save('结果表-新书订购表.xlsx')


